﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Controls_DateInput : System.Web.UI.UserControl, ITextControl, IValueControl<DateTime?>
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    string ITextControl.Text
    {
        get
        {
            return txt.Text;
        }
        set
        {
            txt.Text = value;
        }
    }

    public DateTime? Value
    {
        get
        {
            DateTime d;

            if (DateTime.TryParse(txt.Text, out d) == true)
            {
                return d;
            }
            else
            {
                return null;
            }            
        }
        set
        {
            txt.Text = value.Value.Date.ToString();
        }
    }
}